if (!jQuery) {throw new Error("Requires jQuery")}

/**
 * 获取系统路径
 * @returns {string} 系统路径
 */
function getContentPath() {
    if (ctx) return ctx;
    var pathName = document.location.pathname;
    var index = pathName.substr(1).indexOf("/");
    var path = pathName.substr(0, index + 1);
    return path;
}

// jQuery插件工具默认设置=================================================================================================

if ($.fn.inputlimiter()) {
    /**
     * 设置inputlimiter默认配置
     */
    $.extend($.fn.inputlimiter.defaults, {
        remText: '还可输入%n个字符，',
        limitText: '最多可输入%n个字符。'
    });
}

if ($.mask) {
    /**
     * 设置mask默认验证规则配置
     */
    $.extend($.mask.definitions, {
        '2': "[3|4|5|7|8]",
        '8': "[0-9|X|x]"
    });
}

if ($.fn.datepicker) {
    //http://bootstrap-datepicker.readthedocs.org/en/latest/options.html#id5
    /**
     * 设置datepicker默认配置
     */
    $.extend($.fn.datepicker.defaults, {
        format: 'yyyy-mm-dd',
        language: 'zh-CN',
        todayBtn: 'linked',
        autoclose: true,
        showOtherMonths: true,
        selectOtherMonths: true
    });
    // http://www.bootcss.com/p/bootstrap-datetimepicker/
    $.extend($.fn.datetimepicker.defaults, {
        format: 'yyyy-mm-dd hh:ii',
        language: 'zh-CN',
        todayBtn: 'linked',
        autoclose: true,
        showOtherMonths: true,
        selectOtherMonths: true
    });
}

if ($.fn.select2) {
    /**
     * 设置select2默认配置
     */
    $.extend($.fn.select2.defaults, {
        dropdownAutoWidth: true,
        allowClear: true,
        dropdownCssClass: "bigdrop"
    });
}